/**
 * 字典类型基础定义
 * 提供系统中所有字典类型的枚举定义和模块判断函数
 */

// 基础字典类型枚举
export enum DICT_TYPE {
  // 系统字典类型
  USER_STATUS = 'user_status',
  YES_NO = 'yes_no',
  GENDER = 'gender',
  MENU_TYPE = 'menu_type',
  BUTTON_TYPE = 'button_type',
  ROLE_TYPE = 'role_type',
  DATA_SCOPE = 'data_scope',
  NOTICE_TYPE = 'notice_type',
  NOTICE_STATUS = 'notice_status',
  OPERATE_TYPE = 'operate_type',
  LOGIN_TYPE = 'login_type',
  COMMON_STATUS = 'common_status',
  RESULT_CODE = 'result_code',
  TERMINAL_TYPE = 'terminal_type',
  FILE_STORAGE = 'file_storage',
  
  // BOM字典类型
  BOM_TYPE = 'bom_type',
  BOM_STATUS = 'bom_status',
  LIFECYCLE_STATUS = 'lifecycle_status',
  MATERIAL_TYPE = 'material_type',
  DOCUMENT_TYPE = 'document_type',
  VERSION_STATUS = 'version_status',
  CHANGE_TYPE = 'change_type',
  APPROVAL_STATUS = 'approval_status',
  PRIORITY_LEVEL = 'priority_level',
  UNIT_OF_MEASURE = 'unit_of_measure',
  
  // 产品字典类型
  PRODUCT_STATUS = 'product_status',
  PRODUCT_TYPE = 'product_type',
  PRODUCT_CATEGORY = 'product_category',
  
  // 库存字典类型
  WAREHOUSE_STATUS = 'warehouse_status',
  LOCATION_STATUS = 'location_status',
  TRANSACTION_TYPE = 'transaction_type',
  INVENTORY_CHECK_STATUS = 'inventory_check_status',
  
  // AI字典类型
  MESSAGE_TYPE = 'message_type',
  PLATFORM_TYPE = 'platform_type',
}

// 模块字典类型接口
export interface ModuleDictTypes {
  [moduleName: string]: DICT_TYPE[];
}

// 模块信息接口
export interface ModuleInfo {
  name: string;
  description?: string;
  dictTypes: DICT_TYPE[];
}

/**
 * 判断字典类型是否属于BOM模块
 * @param dictType 字典类型值
 * @returns 是否是BOM模块字典类型
 * @example
 * ```typescript
 * isBOMDictType(DICT_TYPE.BOM_TYPE) // 返回 true
 * isBOMDictType(DICT_TYPE.USER_STATUS) // 返回 false
 * ```
 */
export function isBOMDictType(dictType: string): boolean {
  const bomDictTypes = [
    DICT_TYPE.BOM_TYPE,
    DICT_TYPE.BOM_STATUS,
    DICT_TYPE.LIFECYCLE_STATUS,
    DICT_TYPE.MATERIAL_TYPE,
    DICT_TYPE.DOCUMENT_TYPE,
    DICT_TYPE.VERSION_STATUS,
    DICT_TYPE.CHANGE_TYPE,
    DICT_TYPE.APPROVAL_STATUS,
    DICT_TYPE.PRIORITY_LEVEL,
    DICT_TYPE.UNIT_OF_MEASURE,
  ];
  
  return bomDictTypes.includes(dictType as DICT_TYPE);
}

/**
 * 判断字典类型是否属于系统模块
 * @param dictType 字典类型值
 * @returns 是否是系统模块字典类型
 * @example
 * ```typescript
 * isSystemDictType(DICT_TYPE.USER_STATUS) // 返回 true
 * isSystemDictType(DICT_TYPE.BOM_TYPE) // 返回 false
 * ```
 */
export function isSystemDictType(dictType: string): boolean {
  const systemDictTypes = [
    DICT_TYPE.USER_STATUS,
    DICT_TYPE.YES_NO,
    DICT_TYPE.GENDER,
    DICT_TYPE.MENU_TYPE,
    DICT_TYPE.BUTTON_TYPE,
    DICT_TYPE.ROLE_TYPE,
    DICT_TYPE.DATA_SCOPE,
    DICT_TYPE.NOTICE_TYPE,
    DICT_TYPE.NOTICE_STATUS,
    DICT_TYPE.OPERATE_TYPE,
    DICT_TYPE.LOGIN_TYPE,
    DICT_TYPE.COMMON_STATUS,
    DICT_TYPE.RESULT_CODE,
    DICT_TYPE.TERMINAL_TYPE,
    DICT_TYPE.FILE_STORAGE,
  ];
  
  return systemDictTypes.includes(dictType as DICT_TYPE);
}

/**
 * 判断字典类型是否属于产品模块
 * @param dictType 字典类型值
 * @returns 是否是产品模块字典类型
 * @example
 * ```typescript
 * isProductDictType(DICT_TYPE.PRODUCT_STATUS) // 返回 true
 * isProductDictType(DICT_TYPE.USER_STATUS) // 返回 false
 * ```
 */
export function isProductDictType(dictType: string): boolean {
  const productDictTypes = [
    DICT_TYPE.PRODUCT_STATUS,
    DICT_TYPE.PRODUCT_TYPE,
    DICT_TYPE.PRODUCT_CATEGORY,
  ];
  
  return productDictTypes.includes(dictType as DICT_TYPE);
}

/**
 * 判断字典类型是否属于库存模块
 * @param dictType 字典类型值
 * @returns 是否是库存模块字典类型
 * @example
 * ```typescript
 * isInventoryDictType(DICT_TYPE.WAREHOUSE_STATUS) // 返回 true
 * isInventoryDictType(DICT_TYPE.USER_STATUS) // 返回 false
 * ```
 */
export function isInventoryDictType(dictType: string): boolean {
  const inventoryDictTypes = [
    DICT_TYPE.WAREHOUSE_STATUS,
    DICT_TYPE.LOCATION_STATUS,
    DICT_TYPE.TRANSACTION_TYPE,
    DICT_TYPE.INVENTORY_CHECK_STATUS,
  ];
  
  return inventoryDictTypes.includes(dictType as DICT_TYPE);
}

/**
 * 判断字典类型是否属于AI模块
 * @param dictType 字典类型值
 * @returns 是否是AI模块字典类型
 * @example
 * ```typescript
 * isAIDictType(DICT_TYPE.MESSAGE_TYPE) // 返回 true
 * isAIDictType(DICT_TYPE.USER_STATUS) // 返回 false
 * ```
 */
export function isAIDictType(dictType: string): boolean {
  const aiDictTypes = [
    DICT_TYPE.MESSAGE_TYPE,
    DICT_TYPE.PLATFORM_TYPE,
  ];
  
  return aiDictTypes.includes(dictType as DICT_TYPE);
}